# -*- python -*-
# ex: set syntax=python:

# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# See master.experimental/slaves.cfg for documentation.

slaves = [
  # MAC
  {
    'master': 'Dart',
    'builder': ['vm-mac-debug-ia32'],
    'hostname': 'vm620-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-mac-debug-x64'],
    'hostname': 'vm654-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-mac-release-ia32'],
    'hostname': 'vm681-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-mac-release-x64'],
    'hostname': 'vm666-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dartium-mac-full'],
    'hostname': 'vm619-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64'
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-chrome-mac10.9'],
    'hostname': 'vm642-m3',
    'os': 'mac',
    'version': '10.9',
    'bits': '64'
  },

  # LINUX
  {
    'master': 'Dart',
    'builder': ['vm-linux-debug-ia32'],
    'hostname': 'vm9-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-linux-debug-x64'],
    'hostname': 'vm157-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-linux-release-ia32-asan'],
    'hostname': 'vm36-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-linux-release-x64-asan'],
    'hostname': 'slave37-c3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-linux-release-ia32'],
    'hostname': 'vm11-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-linux-release-x64'],
    'hostname': 'vm158-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-mips-sim-release'],
    'hostname': 'vm19-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-mips-sim-debug'],
    'hostname': 'vm72-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-arm-sim-debug'],
    'hostname': 'vm17-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-arm-sim-release'],
    'hostname': 'vm26-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-arm64-sim-release'],
    'hostname': 'vm160-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-win32-debug'],
    'hostname': 'vm146-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '32',
  },
  {
    'master': 'Dart',
    'builder': ['vm-win32-release'],
    'hostname': 'vm147-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '32',
  },
  {
    'master': 'Dart',
    'builder': ['vm-win64-release'],
    'hostname': 'vm204-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['vm-win64-debug'],
    'hostname': 'vm139-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['target-arm-vm-linux-release'],
    'hostname': 'tazmily-5',
    'os': 'linux',
    'version': 'precise',
    'bits': '32',
  },
  {
    'master': 'Dart',
    'builder': ['vm-linux-release-optcounter-threshold'],
    'hostname': 'vm104-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['new_analyzer-linux-release-stable',
                'analyzer_experimental-linux-release'],
    'hostname': 'vm344-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart-editor-stable',
                'cross-arm-vm-linux-release'],
    'hostname': 'vm93-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart-editor-win-stable',
                'dart-editor-installer-win-stable',
                'dart-sdk-windows'],
    'hostname': 'vm128-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart-editor-installer-mac-stable',
                'dart-editor-mac-stable',
                'dart-sdk-mac'],
    'hostname': 'vm683-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart-editor-linux-stable',
                'dart-sdk-linux'],
    'hostname': 'vm94-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-minified-1-5'],
    'hostname': 'vm100-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-minified-2-5'],
    'hostname': 'vm101-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-minified-3-5'],
    'hostname': 'vm102-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-minified-4-5'],
    'hostname': 'vm103-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-minified-5-5'],
    'hostname': 'vm171-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-checked-1-5'],
    'hostname': 'vm172-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-checked-2-5'],
    'hostname': 'vm173-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-checked-3-5'],
    'hostname': 'vm174-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-checked-4-5'],
    'hostname': 'vm175-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-release-checked-5-5'],
    'hostname': 'vm176-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dartium-lucid64-full'],
    'hostname': 'vm341-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-drt-linux-1-2'],
    'hostname': 'vm97-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-drt-linux-2-2'],
    'hostname': 'vm92-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-drt-linux-csp'],
    'hostname': 'vm98-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-linux-1-4'],
    'hostname': 'vm52-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-linux-2-4'],
    'hostname': 'vm60-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-linux-3-4'],
    'hostname': 'vm67-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-linux-4-4'],
    'hostname': 'vm73-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-win7-ie10-1-4'],
    'hostname': 'vm56-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-win7-ie10-2-4'],
    'hostname': 'vm195-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-win7-ie10-3-4'],
    'hostname': 'vm214-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-win7-ie10-4-4'],
    'hostname': 'vm211-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-win7-ie11-1-4'],
    'hostname': 'vm233-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-win7-ie11-2-4'],
    'hostname': 'vm234-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-win7-ie11-3-4'],
    'hostname': 'vm148-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['full-win7-ie11-4-4'],
    'hostname': 'vm212-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-ie9-win7-all-stable'],
    'hostname': 'vm213-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-ie10-win8-html'],
    'hostname': 'vm236-m3',
    'os': 'win',
    'version': 'win8',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-ie11-win8-html'],
    'hostname': 'vm237-m3',
    'os': 'win',
    'version': 'win8',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-safari-mac10.9-1-3'],
    'hostname': 'vm644-m3',
    'os': 'mac',
    'version': '10.9',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-safari-mac10.9-2-3'],
    'hostname': 'vm656-m3',
    'os': 'mac',
    'version': '10.9',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-safari-mac10.9-3-3'],
    'hostname': 'vm668-m3',
    'os': 'mac',
    'version': '10.9',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-safari-mac10.8'],
    'hostname': 'vm679-m3',
    'os': 'mac',
    'version': '10.8',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-safarimobilesim-mac10.8'],
    'hostname': 'vm669-m3',
    'os': 'mac',
    'version': '10.8',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-jsshell-release-1-4'],
    'hostname': 'vm28-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-jsshell-release-2-4'],
    'hostname': 'vm32-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-jsshell-release-3-4'],
    'hostname': 'vm33-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dart2js-linux-jsshell-release-4-4'],
    'hostname': 'vm34-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },

  # Windows
  {
    'master': 'Dart',
    'builder': ['dartium-win-full-be',
                'dartium-win-full-stable'],
    'hostname': 'vm215-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['pub-win-russian', 'vm-win32-debug-russian'],
    'hostname': 'vm209-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dartium-lucid64-inc-be',
                'dartium-lucid64-inc-integration'],
    'hostname': 'vm345-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dartium-win-full-dev',
                'dartium-win-inc-ninja-be',
                'dartium-win-inc-ninja-integration',
                'dartium-win-full-integration'],
    'hostname': 'vm339-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dartium-mac-inc-be',
                'dartium-mac-inc-integration'],
    'hostname': 'vm604-m3',
    'os': 'mac',
    'version': '10.6',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['dartium-android-release'],
    'hostname': 'build25-a3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  # This machine has specialized setup - please don't move the slave without
  # pinging ricow@
  {
    'master': 'Dart',
    'builder': ['dartium-lucid32-full'],
    'hostname': 'vm342-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['pub-win'],
    'hostname': 'vm208-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '32',
  },
  {
    'master': 'Dart',
    'builder': ['pub-mac'],
    'hostname': 'vm655-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['pub-linux'],
    'hostname': 'vm35-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['pub-mac-debug'],
    'hostname': 'vm630-m3',
    'os': 'mac',
    'version': '10.8',
    'bits': '64'
  },
  {
    'master': 'Dart',
    'builder': ['pub-win-debug'],
    'hostname': 'vm161-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['pub-linux-debug', 'version-checker'],
    'hostname': 'vm206-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
  {
    'master': 'Dart',
    'builder': ['linux-distribution-support-debian_wheezy'],
    'hostname': 'vm153-m3',
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  },
] + [
  # http://crbug.com/151174
  {
    'master': 'DartUnused',
    'hostname': 'vm%d-m3' % i,
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  } for i in [249,250,251,252]
] + [
  {
    'master': 'DartUnused',
    'hostname': 'vm%d-m3' % i,
    'os': 'win',
    'version': 'win8',
    'bits': '64',
  } for i in [164,166,167]
] + [
  {
    'master': 'DartUnused',
    'hostname': 'vm%d-m3' % i,
    'os': 'linux',
    'version': 'precise',
    'bits': '64',
  } for i in [41]
] + [
  {
    'master': 'DartUnused',
    'hostname': 'vm%s-m3' % i,
    'os': 'mac',
    'version': '10.7',
    'bits': '64'
  } for i in []
] + [
  {
    'master': 'DartUnused',
    'hostname': 'vm%s-m3' % i,
    'os': 'mac',
    'version': '10.9',
    'bits': '64'
  } for i in [663]
]


# This is hack to eliminate the need for sharing code between master and
# clients. These channels are replicated in scripts/factory/dart/channels.py.
channel_postfixes = ['-be', '-dev', '-stable', '-integration']

def valid_for_channel(builder, channel):
  """ Returns true if we have this builder on this specific channel"""
  return channel != '-integration' or 'dartium' in builder

def is_channel_builder(builder):
  """Returns true if the builder name is already specific to a channel
  (i.e. the builder ends with a channel postfix)."""
  for postfix in channel_postfixes:
    if builder.endswith(postfix):
      return True
  return False

def duplicate_builders_in_slaves(slaves):
  """Traverses a list of slaves and duplicates the builders associated with each
  slave for every channel. The channels have specified the postfix."""
  for slave in slaves:
    all_builders = []
    for builder in slave.get('builder', ()):
      if ('v8' not in builder
          and not is_channel_builder(builder)):
        for channel in channel_postfixes:
          # Some channels don't have all builders
          if valid_for_channel(builder, channel):
            all_builders.append('%s%s' % (builder, channel))
      else:
        all_builders.append(builder)
    slave['builder'] = all_builders
  return slaves

slaves = duplicate_builders_in_slaves(slaves)
